# 导包
import jsonschema

# 准备被测数据
data = {
    "success": True,
    "code": 10000,
    "message": "操作成功",
    "data": {
        "name": "tom",
        "age":18
    }
}

# 编写jsonschema 格式
schema = {
    "type": "object",
    "properties": {
        "success":{"type": "boolean"},
        "code": {"type": "integer"},
        "message": {"type": "string"},
        "data": {
            "type": "object",
            "properties": {
                "name":{"type": "string"},
                "age": {"type": "integer"}
                          }
                }
                  }
}

# 校验json数据格式
result = jsonschema.validate(instance=data, schema=schema)
print(result)